<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wx_menu', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('微信公众号-菜单表');

            $table->increments('id');
            $table->char('appid', 32)->comment('微信公众号的appid')->default('');
            $table->char('name', 16)->comment('菜单名称')->default('');
            $table->integer('pid')->comment('父类ID')->unsigned()->default(0);
            $table->tinyInteger('type')->comment('类型 1打开子菜单，2回复信息，3打开网页，4打开小程序')->unsigned()->default(1);
            $table->integer('wx_reply_id')->comment('类型是回复的时候，这里不能为空')->unsigned()->default(0);
            $table->string('url', 512)->comment('网页链接')->default('');
            $table->string('miniprogram_url', 512)->comment('小程序链接')->default('');
            $table->string('miniprogram_appid', 32)->comment('类型4的时候，填写的小程序ID')->default('');
            $table->string('pagepath', 512)->comment('类型4的时候，填写的小程序路径')->default('');
            $table->integer('sort')->comment('排序值')->unsigned()->default(0);
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);
            $table->string('creater', 32)->comment('创建人')->default('');

            $table->index('appid');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wx_menu');
    }
};
